<!--
  @Description: 大屏项目列表-首页
  @author: Linh
  @date: 2023-01-05 14:44:44
-->
<template>
  <div class="container">
    <div class="item" v-for="(v, i) in 12" :key="i" @click="gotoDesign(i + 1)">
      <!-- <div style="z-index: 999">project {{ i + 1 }}</div> -->
      <img :src="images[i + 1] || noPhoto" />
    </div>
  </div>
</template>

<script setup lang="ts">
import { useRouter } from "vue-router";
import { ref, computed } from "vue";
import { useCommonStore } from "@/store/modules/common";
import noPhoto from "@/assets/mainPage/noPhoto.png";
const router = useRouter();
const useStore = useCommonStore();

/**
 * 前往设计器
 */
const gotoDesign = (id: number) => {
  router.push({ path: "/design", query: { id } });
};
// 加载失败设置默认图片
const setDefaultImage = (e: any) => {
  e.target.src = noPhoto;
};
const images: any = computed(() => {
  return useStore.imagesList;
});
</script>

<style scoped lang="scss">
.container {
  padding: 24px;
  height: calc(100% - 5vh - 48px);
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;

  .item {
    position: relative;
    height: 20vh;
    width: 20vh;
    margin-right: 24px;
    margin-bottom: 24px;
    border: 1px solid lightblue;
    box-shadow: 2px 2px 5px lightblue;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    img {
      position: absolute;
      width: 100%;
      height: 100%;
      object-fit: scale-down;
    }
    // &:hover {
    //   background-color: lightblue;
    // }

    &:after {
      position: absolute;
      content: "";
      width: 0;
      height: 100%;
      top: 0;
      left: 0;
      direction: rtl;
      z-index: -1;
      box-shadow: -7px -7px 20px 0px #fff9, -4px -4px 5px 0px #fff9, 7px 7px 20px 0px #0002, 4px 4px 5px 0px #0001;
      transition: all 0.3s ease;
    }
    &:hover {
      color: #000;
    }
    &:hover:after {
      left: auto;
      right: 0;
      width: 100%;
    }
    &:active {
      top: 2px;
    }
  }
}
</style>
